package colthgame.app;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.view.View;

public class ClothgameResourceMgr {

	private static ClothgameResourceMgr g_ResourceMgr = new ClothgameResourceMgr();

	public static ClothgameResourceMgr GetInstance() {
		return g_ResourceMgr;
	}

	private ClothgameResourceMgr() {

	}

	public void Init(View _View) {
		m_view = _View;
	}
	
	public void CreateItem()
	{
		for( int nIndex=0 ; nIndex<nTopID.length ; nIndex++ )
		{
			ItemMgr.GetInstance().AddCostume(ItemCostume.E_Layer.eTOP, GetBitmap(nTopID[nIndex]));
		}
		for( int nIndex=0 ; nIndex<nPantsID.length ; nIndex++ )
		{
			ItemMgr.GetInstance().AddCostume(ItemCostume.E_Layer.ePANTS, GetBitmap(nPantsID[nIndex]));
		}
		for( int nIndex=0 ; nIndex<nShoesID.length ; nIndex++ )
		{
			ItemMgr.GetInstance().AddCostume(ItemCostume.E_Layer.eSHOSE, GetBitmap(nShoesID[nIndex]));
		}
		for( int nIndex=0 ; nIndex<nSocksID.length ; nIndex++ )
		{
			ItemMgr.GetInstance().AddCostume(ItemCostume.E_Layer.eSOCKS, GetBitmap(nSocksID[nIndex]));
		}
		for( int nIndex=0 ; nIndex<nNecklaceID.length ; nIndex++ )
		{
			ItemMgr.GetInstance().AddCostume(ItemCostume.E_Layer.eSCARF, GetBitmap(nNecklaceID[nIndex]));
		}
		for( int nIndex=0 ; nIndex<nBangleID.length ; nIndex++ )
		{
			ItemMgr.GetInstance().AddCostume(ItemCostume.E_Layer.eBANGLE, GetBitmap(nBangleID[nIndex]));
		}
		for( int nIndex=0 ; nIndex<nEarringID.length ; nIndex++ )
		{
			ItemMgr.GetInstance().AddCostume(ItemCostume.E_Layer.eRING, GetBitmap(nEarringID[nIndex]));
		}
		for( int nIndex=0 ; nIndex<nHairpinID.length ; nIndex++ )
		{
			ItemMgr.GetInstance().AddCostume(ItemCostume.E_Layer.eHAIRPIN, GetBitmap(nHairpinID[nIndex]));
		}
	}

	public Bitmap GetBitmap(int _nID) {
		Resources resourMgr = m_view.getResources();
		BitmapDrawable drawCharacter = (BitmapDrawable) resourMgr
				.getDrawable(_nID);
		return drawCharacter.getBitmap();
	}

	public int GetInt(int _nID) {
		Resources resourMgr = m_view.getResources();
		return resourMgr.getInteger(_nID);
	}

	public Point GetCostumeOffset(ItemCostume.E_Layer _eLayer) {
		Point result = new Point();
		switch (_eLayer) {
		case eTOP: {
			result.x = GetInt(R.integer.topoffsetx);
			result.y = GetInt(R.integer.topoffsety);
		}
			break;
		case ePANTS: {
			result.x = GetInt(R.integer.pantsoffsetx);
			result.y = GetInt(R.integer.pantsoffsety);
		}
			break;
		case eSHOSE: {
			result.x = GetInt(R.integer.shoseoffsetx);
			result.y = GetInt(R.integer.shoseoffsety);
		}
			break;
		case eSOCKS: {
			result.x = GetInt(R.integer.socksoffsetx);
			result.y = GetInt(R.integer.socksoffsety);
		}
			break;
		case eRING: {
			result.x = GetInt(R.integer.ringoffsetx);
			result.y = GetInt(R.integer.ringoffsety);
		}
			break;
		case eSCARF: {
			result.x = GetInt(R.integer.scarfoffsetx);
			result.y = GetInt(R.integer.scarfoffsety);
		}
			break;
		case eBANGLE: {
			result.x = GetInt(R.integer.bangleoffsetx);
			result.y = GetInt(R.integer.bangleoffsety);
		}
			break;
		case eHAIRPIN: {
			result.x = GetInt(R.integer.hairpinoffsetx);
			result.y = GetInt(R.integer.hairpinoffsety);
		}
			break;
		}
		return result;
	}
	
	public Point GetCostumeCollisionSize(ItemCostume.E_Layer _eLayer) {
		Point result = new Point();
		switch (_eLayer) {
		case eTOP: {
			result.x = GetInt(R.integer.topcollisionx);
			result.y = GetInt(R.integer.topcollisiony);
		}
			break;
		case ePANTS: {
			result.x = GetInt(R.integer.pantscollisionx);
			result.y = GetInt(R.integer.pantscollisiony);
		}
			break;
		case eSHOSE: {
			result.x = GetInt(R.integer.shosecollisionx);
			result.y = GetInt(R.integer.shosecollisiony);
		}
			break;
		case eSOCKS: {
			result.x = GetInt(R.integer.sockscollisionx);
			result.y = GetInt(R.integer.sockscollisiony);
		}
			break;
		case eRING: {
			result.x = GetInt(R.integer.ringcollisionx);
			result.y = GetInt(R.integer.ringcollisiony);
		}
			break;
		case eSCARF: {
			result.x = GetInt(R.integer.scarfcollisionx);
			result.y = GetInt(R.integer.scarfcollisiony);
		}
			break;
		case eBANGLE: {
			result.x = GetInt(R.integer.banglecollisionx);
			result.y = GetInt(R.integer.banglecollisiony);
		}
			break;
		case eHAIRPIN: {
			result.x = GetInt(R.integer.hairpincollisionx);
			result.y = GetInt(R.integer.hairpincollisiony);
		}
			break;
		}
		return result;
	}

	private View m_view;
	private Integer[] nTopID = {
             R.drawable.ek_knitwear,
             R.drawable.ek2_blueknitwear,
             R.drawable.ek2_pinkdress2,
             R.drawable.ek_blacktop,
	};
	private Integer[] nPantsID = {
            R.drawable.ek2_graypants,
            R.drawable.ek2_whiteskirt,
	};
	private Integer[] nShoesID = {
            R.drawable.ek_whiteshoes,
            R.drawable.ek2_blackshoes5,
            R.drawable.ek2_goldshoes,
	};
	private Integer[] nSocksID = {
            R.drawable.ek2_blacksock4,
	};
	private Integer[] nEarringID = {
            R.drawable.bear_earring,
            R.drawable.pink_earring,
            R.drawable.red_earring,
	};
	private Integer[] nHairpinID = {
            R.drawable.bangwool_hairpin,
            R.drawable.ticktackpin_blue,
            R.drawable.yellow_hairpin,
	};
	private Integer[] nBangleID = {
            R.drawable.ek_puplebangle,
            R.drawable.ek_whitebangle,
	};
	private Integer[] nNecklaceID = {
            R.drawable.ek_greenneckace,
            R.drawable.ek2_pinkscarf1,
	};

}
